package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysSchoolScore;
import com.ruoyi.system.service.ISysSchoolScoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 操行分信息Controller
 * 
 * @author 杨皓焜
 * @date 2021-01-31
 */
@RestController
@RequestMapping("/system/score")
public class SysSchoolScoreController extends BaseController
{
    @Autowired
    private ISysSchoolScoreService sysSchoolScoreService;

    /**
     * 查询操行分信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:score:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysSchoolScore sysSchoolScore)
    {
        startPage();
        List<SysSchoolScore> list = sysSchoolScoreService.selectSysSchoolScoreList(sysSchoolScore);
        return getDataTable(list);
    }

    /**
     * 导出操行分信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:score:export')")
    @Log(title = "操行分信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysSchoolScore sysSchoolScore)
    {
        List<SysSchoolScore> list = sysSchoolScoreService.selectSysSchoolScoreList(sysSchoolScore);
        ExcelUtil<SysSchoolScore> util = new ExcelUtil<SysSchoolScore>(SysSchoolScore.class);
        return util.exportExcel(list, "score");
    }

    /**
     * 获取操行分信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:score:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sysSchoolScoreService.selectSysSchoolScoreById(id));
    }

    /**
     * 新增操行分信息
     */
    @PreAuthorize("@ss.hasPermi('system:score:add')")
    @Log(title = "操行分信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSchoolScore sysSchoolScore)
    {
        sysSchoolScore.setCreateBy(SecurityUtils.getUsername());
        return toAjax(sysSchoolScoreService.insertSysSchoolScore(sysSchoolScore));
    }

    /**
     * 修改操行分信息
     */
    @PreAuthorize("@ss.hasPermi('system:score:edit')")
    @Log(title = "操行分信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSchoolScore sysSchoolScore)
    {
        sysSchoolScore.setUpdateBy(SecurityUtils.getUsername()
        );
        return toAjax(sysSchoolScoreService.updateSysSchoolScore(sysSchoolScore));
    }

    /**
     * 删除操行分信息
     */
    @PreAuthorize("@ss.hasPermi('system:score:remove')")
    @Log(title = "操行分信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysSchoolScoreService.deleteSysSchoolScoreByIds(ids));
    }
}
